﻿#ifndef SENSERCONNECT_H
#define SENSERCONNECT_H


#include <Ice/Ice.h>
#include <QString>
#include "senserclient.h"

class SenserConnect
{
public:
    explicit SenserConnect();
    ~SenserConnect();

    //启动连接
    void start();
    void openAdapter();
    void closeAdapter();
    //断开连接
    void disConnect();
    //停止连接线程
    void stop();
    //设置链接参数
    void setConnectParam(QString &connectName,QString &address,int &port);

private:
    void connectProcess();
    void iceConnectSuccess();
    void iceConnectError(const std::string message);
private:
    QString m_connectName; //链接名称
    QString m_address;    //服务端地址
    int m_port;      //服务端端口

    bool m_run_state; //运行状态
    bool m_connect_state; //连接状态
    bool m_adapter_state;

    std::shared_ptr<std::thread> m_thread;

    std::shared_ptr<SenserClient> m_senser_client;

    std::shared_ptr<Ice::Communicator> m_communicator;
    Ice::ObjectAdapterPtr m_ice_adapter_ptr;
    std::shared_ptr<desig::slice_api::ClientPrx> m_client_prx;
    std::shared_ptr<desig::slice_api::ServerPrx> m_server_prx;
};

#endif // SENSERCONNECT_H
